package com.alaia.coupon.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alaia.coupon.domain.SkuLadder;
import com.alaia.coupon.service.ISkuLadderService;
import com.alaia.common.web.controller.BaseController;
import com.alaia.common.web.domain.AjaxResult;
import com.alaia.common.web.page.TableDataInfo;

/**
 * 商品阶梯价格Controller
 * 
 * @author Alaia
 * @date 2022-11-01
 */
@RestController
@RequestMapping("/coupon/ladder")
public class SkuLadderController extends BaseController
{
    @Autowired
    private ISkuLadderService skuLadderService;

    /**
     * 查询商品阶梯价格列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SkuLadder skuLadder)
    {
        startPage();
        List<SkuLadder> list = skuLadderService.selectSkuLadderList(skuLadder);
        return getDataTable(list);
    }


    /**
     * 获取商品阶梯价格详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(skuLadderService.selectSkuLadderById(id));
    }

    /**
     * 新增商品阶梯价格
     */
    @PostMapping
    public AjaxResult add(@RequestBody SkuLadder skuLadder)
    {
        return toAjax(skuLadderService.insertSkuLadder(skuLadder));
    }

    /**
     * 修改商品阶梯价格
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SkuLadder skuLadder)
    {
        return toAjax(skuLadderService.updateSkuLadder(skuLadder));
    }

    /**
     * 删除商品阶梯价格
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(skuLadderService.deleteSkuLadderByIds(ids));
    }
}
